
package apk.yoursms.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;

public class SmsDbHelper  extends SQLiteOpenHelper implements BaseColumns {       
    
    public static final String TABLE_NAME = "smsbox";
    public static final String TABLE_NAME_EN = "smsbox_en";
    public static final String GROUP = "sms_group";
    public static final String SMS_TEXT = "sms_text";
    public static final String SMS_CATEGORY = "sms_category";
    public static final String SMS_SITE = "sms_site";    

    public static final String TABLE_NAME_CATEGORY_RU = "category_ru";
    public static final int DB_VERSION = 2;
    

    public SmsDbHelper(Context context) {
	super(context, SmsProvider.DB_SMSBOX, null, DB_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {		
	db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_NAME
		+ " (_id INTEGER PRIMARY KEY AUTOINCREMENT, " + GROUP
		+ " TEXT, " + SMS_TEXT + " TEXT, " + SMS_CATEGORY + " TEXT, "
		+ SMS_SITE + " TEXT);");	
	
	db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_NAME_EN
		+ " (_id INTEGER PRIMARY KEY AUTOINCREMENT, " + GROUP
		+ " TEXT, " + SMS_TEXT + " TEXT, " + SMS_CATEGORY + " TEXT, "
		+ SMS_SITE + " Text);");	
	
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
	db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
	db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME_EN);
	onCreate(db);
    }
}
